package com.school.express.controller;

import com.school.express.domain.Express;
import com.school.express.domain.Sign;
import com.school.express.service.ExpressService;
import com.school.express.service.SignService;
import com.school.support.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import zhibi.common.support.exception.MessageException;

/**
 * Created by 执笔 on 2017/3/23.
 */
@RequestMapping("sign")
@Controller
public class SignController extends BaseController {

    @Autowired
    private SignService signService;
    @Autowired
    private ExpressService expressService;

    @RequestMapping("signV")
    public String signV(Integer expressId, Model model){
        Express express =expressService.selectByPK(expressId);
        if(null == express){
            throw new MessageException("该快递不存在");
        }
        model.addAttribute(express);
        return "express/sign";
    }

    @RequestMapping("sign")
    public String sign(Sign sign){
        signService.sign(sign);
        return redirect("/express/tranList");
    }
}
